
import VueToast from '@/components/toast/index.vue'

import { render, h } from 'vue'
export default function install(App) {
  let vNode = h({
    data() {
      return {
        isShow: false,
        content: "自定义文本",
        type:""
      }
    },
    render() {
      return h(h(VueToast), { 'options': this.isShow, 'content':this.content,'type':this.type });
    }
  })

  const vNodeDom = document.createElement('div')
  document.body.appendChild(vNodeDom)
  vNode.appContext = App._context
  render(vNode, vNodeDom)

  App.config.globalProperties.$show = function (data) {
    vNode.component.proxy.isShow = true;
    vNode.component.proxy.content = data.content;
    vNode.component.proxy.type = data.type;
    render(vNode, vNodeDom);

    setTimeout(() => {
      vNode.component.proxy.isShow = false;
      render(vNode, vNodeDom);
    }, 3000);

  }

  App.config.globalProperties.$hide = function () {
    vNode.component.proxy.isShow = false;
    render(vNode, vNodeDom);
  }
}

